package baseTest;

import java.util.HashSet;

public class longestConsecutive {
    public static void main(String[] args) {
        int[] arr = {0,3,7,2,5,8,4,6,0,1};
        System.out.println(process(arr));
    }
    public static int process(int[] nums){
        HashSet<Integer> set = new HashSet<>();
        for (int n : nums) {
            set.add(n);
        }
        int seqLen = 0;
        int maxLne = 0;
        for (int cur: nums) {
            if (!set.contains(cur-1)){
                seqLen = 1;
                while (set.contains(cur+1)){
                    cur++;
                    seqLen++;
                }
            }
            maxLne = Math.max(seqLen,maxLne);
        }
        return maxLne;
    }
}
